//
//  ZLWAVManager.m
//  EPA
//
//  Created by lanou3g on 16/4/21.
//  Copyright © 2016年 zlw. All rights reserved.
//

#import "ZLWAVManager.h"

@interface ZLWAVManager ()
/**
 *  播放器,需要在管理中用
 */
@property (nonatomic, strong)AVPlayer *avplayer;

@end

@implementation ZLWAVManager
+ (instancetype)shareManager
{
    static ZLWAVManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (manager == nil) {
            manager = [ZLWAVManager new];
            manager.avplayer = [[AVPlayer alloc] init];
        }
    });
    return manager;
}
-(void)Play
{
    AVPlayerItem *item = self.itemArray[self.currentIndex];
    [self.avplayer replaceCurrentItemWithPlayerItem:item];
    [self.avplayer play];
}
-(void)Pause
{
    [self.avplayer pause];
}
-(void)previous
{
    self.currentIndex--;
    if (self.currentIndex < 0) {
        self.currentIndex = self.itemArray.count - 1;
    }
    [self Play];
}

-(void)Next
{
    self.currentIndex++;
    if (self.currentIndex >= self.itemArray.count) {
        self.currentIndex = 0;
    }
    [self Play];
}

-(void)SeekToTime:(CMTime)time
{
    [self.avplayer seekToTime:time];
}




@end
